import axios from 'axios';
new Vue({
    data() {
        return {
            form: {
                screen_name: '',
                description: '',
                email: '',
                phone: '',
                password: ''
            },
            showPassword: false,
        };
    },
    methods: {
        async saveChanges() {
            try {
                const userId = 1; // 假设这是当前用户的ID，实际情况中应该从session或token中获取

                await axios.put('/api/users/' + userId + '/name', { newUserName: this.form.screen_name });
                await axios.put('/api/users/' + userId + '/introduce', { newUserIntroduce: this.form.description });
                await axios.put('/api/users/' + userId + '/email', { newUserEmail: this.form.email });
                await axios.put('/api/users/' + userId + '/phone', { newUserPhone: this.form.phone });
                await axios.put('/api/users/' + userId + '/password', { newUserPassword: this.form.password });

                alert('信息已成功更新！');
            } catch (error) {
                console.error('Error updating user information:', error);
                alert('更新信息时发生错误，请检查您的网络连接或稍后再试。');
            }
        }
    }

}).$mount("#app");